<ui:composition  xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:a4j="http://richfaces.org/a4j"
                 xmlns:rich="http://richfaces.org/rich"
                 xmlns:c="http://java.sun.com/jsp/jstl/core"
                 xmlns:fn="http://java.sun.com/jsp/jstl/functions">
    <h:head>
        <title>中国地震局财务信息服务平台</title>
        <style type="text/css">
            input[type='submit']{
                margin:3px 5px 3px 5px;
                padding:3px 5px 3px 5px;
            }
        </style>
    </h:head>
    <h:form>
        <rich:panel header="个人党费" id="ipanel" styleClass="content-hight">
            <h:outputText value="查询日期："/>
            <h:panelGroup id="purchDate">
                <rich:calendar value="#{dangHuiQueryBean.beginDate}"
                               locale="zh_CN"
                               popup="true"                      
                               showWeekDaysBar="false"
                               datePattern="yyyy年MM月"
                               showApplyButton="false"
                               style="width:180px">
                </rich:calendar>
                至
                <rich:calendar value="#{dangHuiQueryBean.endDate}"
                               locale="zh_CN"
                               popup="true"
                               showWeekDaysBar="false"
                               datePattern="yyyy年MM月"
                               showApplyButton="false"
                               style="width:180px"/>
            </h:panelGroup>
            <a4j:commandButton id="queryButton" value="查询"
                               action="#{dangHuiQueryBean.queryDangFeiForPerson_date}"
                               render="ipanel"
                               onclick="this.disabled = 'true';"/>
            <h:commandButton id="ebutton" value="导出Excel"
                             action="#{dangHuiQueryBean.exportExcel}"
                             disabled="#{dangHuiQueryBean.dangData == null}" /> 
            <rich:messages/>
            <hr/>           
            <h:panelGroup id="tableGroup">
                <rich:dataScroller for="editTable" execute="@this" render="tableGroup" fastStep="3"/>
                <div style="width:750px;min-height:200px;overflow:auto;">
                    <rich:dataTable id="editTable" value="#{dangHuiQueryBean.dangData}"
                                    var="explist" rowKeyVar="rowKey" rows="15"
                                    styleClass="stable"
                                    style="width: 100%;margin-bottom: 5px;" 
                                    noDataLabel="无数据!">
                        <f:facet name="header">
                            <rich:columnGroup>
                                <c:forEach items="#{dangHuiQueryBean.dangHeader}" var="hrow" varStatus="hstatus">
                                    <c:if test="#{hstatus.index eq 0}">
                                        <c:forEach items="#{hrow}" var="co" varStatus="status">
                                            <c:if test="#{status.index le 1}">
                                                <rich:column rowspan="2">
                                                    <h:outputText value="#{co}"/>
                                                </rich:column>
                                            </c:if>
                                            <c:if test="#{status.index eq 2}">
                                                <rich:column colspan="#{fn:length(dangHuiQueryBean.dangAddArr)}">
                                                    <h:outputText value="#{co}"/>
                                                </rich:column>
                                            </c:if>
                                            <c:if test="#{status.index gt 2}">
                                                <c:if test="#{empty dangHuiQueryBean.dangCutArr}">
                                                    <c:if test="#{status.index gt 2}">
                                                        <rich:column rowspan="2">
                                                            <h:outputText value="#{co}"/>
                                                        </rich:column>
                                                    </c:if>
                                                </c:if>
                                                <c:if test="#{not empty dangHuiQueryBean.dangCutArr}">
                                                    <c:if test="#{status.index eq 3}">
                                                        <rich:column colspan="#{fn:length(dangHuiQueryBean.dangCutArr)}">
                                                            <h:outputText value="#{co}"/>
                                                        </rich:column>
                                                    </c:if>
                                                    <c:if test="#{status.index gt 3}">
                                                        <rich:column rowspan="2">
                                                            <h:outputText value="#{co}"/>
                                                        </rich:column>
                                                    </c:if>
                                                </c:if>
                                            </c:if>
                                        </c:forEach>
                                    </c:if>
                                    <c:if test="#{hstatus.index eq 1}">
                                        <c:forEach items="#{hrow}" var="co" varStatus="status">
                                            <c:if test="#{status.index eq 0}">
                                                <rich:column breakRowBefore="true">
                                                    <h:outputText value="#{co}"/>
                                                </rich:column>
                                            </c:if>
                                            <c:if test="#{!(status.index eq 0)}">
                                                <rich:column>
                                                    <h:outputText value="#{co}"/>
                                                </rich:column>
                                            </c:if>
                                        </c:forEach>
                                    </c:if>
                                </c:forEach>
                            </rich:columnGroup>
                        </f:facet>
                        <c:forEach begin="0" end="#{fn:length(dangHuiQueryBean.dangData[0])-1}" step="1" var="col">
                            <c:if test="#{col le 1}">
                                <rich:column style="text-align: center">
                                    <h:outputText value="#{explist[col]}"/>
                                </rich:column>
                            </c:if>
                            <c:if test="#{col gt 1}">
                                <rich:column style="text-align: right">
                                    <h:outputText value="#{explist[col]}">
                                        <f:convertNumber pattern="#,##0.00" type="number"/>
                                    </h:outputText>
                                </rich:column>
                            </c:if>
                        </c:forEach>
                    </rich:dataTable>
                        <rich:jQuery selector=".stable tr:odd" query="addClass('odd-row')" />
                        <rich:jQuery selector=".stable tr:even" query="addClass('even-row')" />
                        <rich:jQuery selector=".stable tr" event="mouseover" query="jQuery(this).addClass('active-row')" />
                        <rich:jQuery selector=".stable tr" event="mouseout" query="jQuery(this).removeClass('active-row')" />
                        <rich:jQuery selector=".stable tr" event="click" query="jQuery(this).addClass('click-row')"/>
                        <rich:jQuery selector=".stable tr" event="click" query="jQuery('.stable tr').not(this).removeClass('click-row')"/>
                </div>
            </h:panelGroup>
        </rich:panel>
    </h:form>
</ui:composition>